home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / Text Capture FKEY / Text Capture source.cpt / _* Overview *_.c < prev    next >
Text File  |  1992-06-12  |  2KB  |  50 lines

  1. #if justacomment
  2.  
  3.        Text Capture FKEY
  4.      by James W. Walker, 1992.
  5.      76367.2271@compuserve.com
  6.  
  7. Copies text from the front window to the clipboard, for applications
  8. like THINK Reference 1.0 that do not support normal copying.
  9.  
  10. Main routine:
  11.     * Make a locked copy of itself and call it.  This is because
  12.         the Event Manager unlocks an FKEY after running it, but our
  13.         patches need to stay around longer.
  14.     * Find and read the preferences file, or if it is not found,
  15.         create it.
  16.     * If caps lock or control is down, show the configuration dialog,
  17.         then quit.  Otherwise proceed normally.
  18.     * Depending on the preferences, maybe change the cursor to a cross-
  19.         hair and wait for the user to select a rectangle.
  20.     * Invalidate the front window, or a part thereof.
  21.     * Patch _BeginUpDate and _EndUpDate.
  22.  
  23. _BeginUpDate patch:
  24.     * When there is an update event for the front window,
  25.         call Begin_copy().
  26.  
  27. Begin_copy():
  28.     * create a new GrafPort for the TEHandle
  29.     * create TEHandle for captured text
  30.     * patch stdText bottleneck for front window
  31.  
  32. stdText patch:
  33.     * Accumulate styled text into TEHandle.  Use the vertical
  34.     coordinate to tell whether we're on a new line, in which case
  35.     we may want to insert a return as a line separator.
  36.  
  37. _EndUpDate patch:
  38.     * After the update event for the front window,
  39.         call End_copy().
  40.     * Use some assembly language trickery to dispose of the handle
  41.     containing the patch.
  42.  
  43. End_copy():
  44.     * unpatch stdText
  45.     * put text on clipboard
  46.     * dispose of TEHandle
  47.     * close our GrafPort
  48.     * unpatch _BeginUpDate and _EndUpDate.
  49.  
  50. #endif